﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WinLogicUniversity.DBBroker
{
    public class CategoryBroker
    {
        static LogicUniversityT2Entities entity = new LogicUniversityT2Entities();


        #region AutoGen

        public static string AutoGenCategoryID()
        {
            int intId = 0; string CID;
            try
            {
                intId = Convert.ToInt32(entity.Categories.Max(g => g.CategoryID).Substring(1));
            }
            catch (NullReferenceException)
            {
                CID = "C001";
                return CID;
            }
            finally
            {
                int MaxCID = Convert.ToInt32(intId) + 1;
                CID = string.Format("C{0:000}", MaxCID);
            }
            return CID;
        }
       

        #endregion
    }
}
